<%@ LANGUAGE = VBScript%>
<%
	Session("FormName")=""
%>
<!--#include file="..\CheckSession.inc"-->
<!--#include file="..\pageSelected.inc"-->
<HTML>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title></title>
</head>
<%
	'set Conn=server.CreateObject("ADODB.Connection")
	'Conn.Open Application("StrConn")	
	sSQL="Select top 1 tongdai from phone"
	Set RecTD=server.createobject("ADODB.Recordset")
	RecTD.cursortype=3
	RecTD.CacheSize=5
	RecTD.open sSQL,Conn
	if RecTD.recordcount then
		bTD=RecTD("Tongdai")
	end if
	RecTD.close
	Set RecTD=nothing
	Set ClsFun=server.CreateObject("Vinalines.ClsFunction")
	Dim bLink
	bComm=trim(Request("bComm"))	
	bHoten=Trim(Request("TxtHoten"))
	bCoquan=Trim(Request("TxtCQ"))
	bPhoneCQ=Trim(Request("TxtPhoneCQ"))
	bPhone=Trim(Request("TxtPhone"))
	bPhoneNR=Trim(Request("TxtPhoneNR"))
	bPhoneDD=Trim(Request("TxtPhoneDD"))
	bDisplay=Trim(Request("bDisplay"))
	bIDPhone=Trim(Request("TxtMa"))
	bTongdai=Trim(Request("TxtTongdai"))
	bFax=Trim(Request("TxtFax"))
	bEmail=Trim(Request("TxtEmail"))
	bIDNhom=Trim(Request("CommboNhom"))
	if bDisplay="ok" then
		sSQL="Select * from Phone Where IDPhone="& Request("bIDPhone")
		Set RecD=server.CreateObject("ADODB.Recordset")
		RecD.CursorType=3
		RecD.CacheSize=5
		RecD.Open sSQL,Conn
		if RecD.RecordCount then
			bHoten=Trim(RecD("Hoten"))
			bCoquan=Trim(RecD("Coquan"))
			bEmail=Trim(RecD("Email"))
			bTongdai=Trim(RecD("Tongdai"))
			bFax=Trim(RecD("Fax"))
			bPhoneCQ=Trim(RecD("PhoneCQ"))
			bPhone=Trim(RecD("Phone"))
			bPhoneNR=Trim(RecD("PhoneNR"))
			bPhoneDD=Trim(RecD("PhoneDD"))
			bIDPhone=Trim(RecD("IDPhone"))
			bIDNhom=Trim(RecD("IDNhom"))
			
		end if
	end if
	if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),"F27",1)="1" or Session("IsAdmin") then
		Select Case bComm
			Case "add"
				sSQL="Insert into Phone(Hoten,Coquan,PhoneCQ,Phone,PhoneNR,PhoneDD,Email,Tongdai,Fax,IDNhom) values('"& bHoten &"','"& ClsFun.ModiString(bCoquan) &"','"& ClsFun.ModiString(bPhoneCQ) &"','"& ClsFun.ModiString(bPhone) &"','"& ClsFun.ModiString(bPhoneNR) &"','"& ClsFun.ModiString(bPhoneDD) &"','"& ClsFun.ModiString(bEmail) &"','"& ClsFun.ModiString(bTongdai) &"','"& ClsFun.ModiString(bFax) &"','"& ClsFun.ModiString(bIDNhom) &"')"
				Conn.Execute sSQL				
				bMsg="Th&#244;ng tin &#273;&#227; &#273;&#432;&#7907;c c&#7853;p nh&#7853;t"
			case "delete"
				sSQL="Delete from Phone Where IDPhone = "& bIDPhone
				Conn.Execute sSQL	
				bMsg="Th&#244;ng tin &#273;&#227; &#273;&#432;&#7907;c xo&#225;"
			case "edit"
				sSQL="Update Phone set Hoten='"& ClsFun.ModiString(bHoten) _
					&"',Coquan='"& ClsFun.ModiString(bCoquan) _
					&"',PhoneCQ='"& ClsFun.ModiString(bPhoneCQ) _
					&"',Phone='"& ClsFun.ModiString(bPhone) _
					&"',PhoneNR='"& ClsFun.ModiString(bPhoneNR) _
					&"',PhoneDD='"& ClsFun.ModiString(bPhoneDD) _
					&"',Tongdai='"& ClsFun.ModiString(bTongdai) _
					&"',Fax='"& ClsFun.ModiString(bFax) _
					&"',Email='"& ClsFun.ModiString(bEmail) _
					&"',IDnhom='"& ClsFun.ModiString(bIDNhom) _
					&"' Where IDPhone = " & bIDPhone
				Conn.Execute sSQL
				sSQL="Update Phone set tongdai ='"& ClsFun.ModiString(bTongdai) &"'"
				Conn.Execute sSQL
				bMsg="Th&#244;ng tin &#273;&#227; &#273;&#432;&#7907;c s&#7917;a"
		End Select
	end if
	Set Rec=server.CreateObject("ADODB.Recordset") 
	rec.CursorType = 3
	rec.CacheSize=5	
	select case request("bComm")
		case "search"	
			sSQL="SELECT Tennhom, Phone.* FROM Phone INNER JOIN Nhom ON Phone.IDNhom = Manhom"
			'sSQL="Select * from Phone where Hoten like '%"& ClsFun.ModiString(bHoten) & "%'"
			sSQL=sSQL+" where Hoten like '%"& ClsFun.ModiString(bHoten) & "%'"
			sSQL=sSQL+" And Coquan like '%"& ClsFun.ModiString(bCoquan) & "%'"
			sSQL=sSQL+" And PhoneCQ like '%"& ClsFun.ModiString(bPhoneCQ) & "%'"
			sSQL=sSQL+" And Phone like '%"& ClsFun.ModiString(bPhone) & "%'"
			sSQL=sSQL+" And PhoneNR like '%"& ClsFun.ModiString(bPhoneNR) & "%'"
			sSQL=sSQL+" And PhoneDD like '%"& ClsFun.ModiString(bPhoneDD) & "%'"
			sSQL=sSQL+" And Email like '%"& ClsFun.ModiString(bEmail) & "%'"
			sSQL=sSQL+" And Tongdai like '%"& ClsFun.ModiString(bTongdai) & "%'"
			sSQL=sSQL+" And Fax like '%"& ClsFun.ModiString(bFax) & "%'"
			sSQL=sSQL+" And IDNhom like '%"& ClsFun.ModiString(bIDNhom) & "%'  order by nhom.STT,Phone.IDNhom"
		case else
			Loaitim=""
			bsearch=""
			'ssql="Select * from Phone order by IDNhom"
			sSQL="SELECT Tennhom, Phone.* FROM Phone INNER JOIN Nhom ON Phone.IDNhom = Manhom order by nhom.STT,Phone.IDNhom"
	end select
	Dim nRecCount	' Number of records found
	Dim nPageCount	' Number of pages of records we have
	Dim nPage	' Current page number
	nPage=CLng(request("Page"))	
	if nPage="" then nPage=1
	rec.Open ssql,Conn
	if  rec.EOF and rec.BOF then
		nPageCount=0
	end if	
%>
<script language=VBScript runat=server>
Function Paging(ByVal intPage, ByVal intPageCount, ByVal intRecordCount)
	Dim strQueryString
	Dim strScript
	Dim intStart
	Dim intEnd
	Dim strRet
	Dim i

	If intPage > intPageCount Then
		intPage = intPageCount
	ElseIf intPage < 1 Then 
		intPage = 1
	End If
	
	If intRecordCount = 0 Then
		'strRet = "No Records Found"
	ElseIf intPageCount = 1 Then
		'strRet = "End Of Hits"
	Else
		For i = 1 To Request.QueryString.Count
			If LCase(Request.QueryString.Key(i)) <> "page" Then
				strQueryString = strQueryString & "&" 
				strQueryString = strQueryString & Server.URLEncode(Request.QueryString.Key(i)) & "=" 
				strQueryString = strQueryString & Server.URLEncode(Request.QueryString.Item(i))
			End If
		Next

		For i = 1 To Request.Form.Count
			If LCase(Request.Form.Key(i)) <> "page" Then
				strQueryString = strQueryString & "&" 
				strQueryString = strQueryString & Server.URLEncode(Request.Form.Key(i)) & "=" 
				strQueryString = strQueryString & Server.URLEncode(Request.Form.Item(i))
			End If
		Next

		If Len(strQueryString) <> 0 Then
			strQueryString = "?" & Mid(strQueryString, 2) & "&"
		Else
			strQueryString = "?"
		End If

		strScript = Request.ServerVariables("SCRIPT_NAME") & strQueryString
	
		If intPage <= 10 Then
			intStart = 1
		Else
			If (intPage Mod 10) = 0 Then
				intStart = intPage - 9
			Else
				intStart = intPage - (intPage Mod 10) + 1
			End If
		End If

		intEnd = intStart + 9
		If intEnd > intPageCount Then intEnd = intPageCount
	
		'strRet = "Page " & intPage & " of " & intPageCount & ": "
	
		If intPage > 10 Then 
			strRet = strRet & "<a href=""" & strScript
			strRet = strRet & "page=" & intPage - 10 
			strRet = strRet & """><IMG border=0 SRC=../images/prev.gif></a> "
		End If
	
		For i = intStart To intEnd
			If i = intPage Then
				strRet = strRet & "<b><font color=A90A08>" & i & "</font></b> "
			Else
				strRet = strRet & "<a href=""" & strScript
				strRet = strRet & "page=" & i 
				strRet = strRet & """>" & i & "</a>"
				If i <> intEnd Then strRet = strRet & " "
			End If
		Next
	
		If intPage <> intPageCount and intPageCount > 10 Then
			strRet = strRet & " <a href=""" & strScript
			strRet = strRet & "page=" & intPage + 10 
			strRet = strRet & """><IMG border=0 SRC=../images/next.gif></a> "
		End If
	End If
	
	Paging = strRet
End Function
</script>
<!--#include file="..\jvfunction.inc"-->
<LINK href="../styles/styles.css" type=text/css rel=STYLESHEET>
<body style="FONT-FAMILY: arial" bgcolor=#F8F9D9 topmargin=0 leftmargin=0 onload="SetFocus()">
<%if bMsg<>"" then %><p align=center><font face="Times New Roman" size=3 color="red"><%=bMsg%></font></p>
<%end if%>
<form name=frm method=post>
<Input type=hidden name="strURL" value="">
<p align=center><b><font FACE="Times New Roman" size="3">DANH BẠ ÐIỆN THOẠI</font></b>
<!-- Buttons -->
<table bgColor="#bdd5d0" border="0" width="100%" style="BORDER-BOTTOM-STYLE: none; BORDER-LEFT-STYLE: solid; BORDER-RIGHT-STYLE: solid; BORDER-TOP-STYLE: solid;Border-color:#C0C0C0" cellspacing=1 cellpadding=0>
  <tbody>
    <tr bgColor="#bdd5d0">
      	<%if bDisplay="ok" then%>
			<%if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),"F27",1)="1"  or Session("IsAdmin") then%>
				<td width="17%"><Button language="javascript"  name="CmdAdd" onclick="return CmdAdd_onclick()" style=" POSITION: relative; WIDTH:100%" accesskey="T"><u>T</u>hêm</Button></td>
				<td width="17%"><Button language="javascript" name="CmdDelete" onclick="return CmdDelete_onclick()" style=" POSITION: relative; WIDTH:100%" accesskey="X"><u>X</u>óa</Button></td>
				<td width="17%"><Button language="javascript" name="CmdEdit" onclick="return CmdEdit_onclick()" style=" POSITION: relative; WIDTH:100%" accesskey="S"><u>S</u>ửa</Button></td>
				<td width="17%"><Button disabled language="javascript" name="CmdOK" onclick="return CmdOK_onclick()" style="POSITION: relative; WIDTH:100%" accesskey="G"><p><u>G</u>hi nhận</p></Button></td>
				<td width="16%"><Button disabled language="javascript" name="CmdCancel" onclick="return CmdCancel_onclick()" style="POSITION: relative; WIDTH:100%" accesskey="B"><p><u>B</u>ỏ qua</p></Button></td>
			<%else%>
				<td width="17%"><Button language="javascript" disabled name="CmdAdd" onclick="return CmdAdd_onclick()" style=" POSITION: relative; WIDTH:100%" accesskey="T"><u>T</u>hêm</Button></td>
				<td width="17%"><Button language="javascript" disabled name="CmdDelete" onclick="return CmdDelete_onclick()" style=" POSITION: relative; WIDTH:100%" accesskey="X"><u>X</u>óa</Button></td>
				<td width="17%"><Button language="javascript" disabled name="CmdEdit" onclick="return CmdEdit_onclick()" style=" POSITION: relative; WIDTH:100%" accesskey="S"><u>S</u>ửa</Button></td>
				<td width="17%"><Button language="javascript" disabled name="CmdOK" onclick="return CmdOK_onclick()" style="POSITION: relative; WIDTH:100%" accesskey="G"><p><u>G</u>hi nhận</p></Button></td>
				<td width="16%"><Button language="javascript" disabled name="CmdCancel" onclick="return CmdCancel_onclick()" style="POSITION: relative; WIDTH:100%" accesskey="B"><p><u>B</u>ỏ qua</p></Button></td>
			<%end if%>
			<td width="16%"><Button language="javascript" name="CmdSearch" onclick="return CmdSearch_onclick()" style="POSITION: relative; WIDTH:100%" accesskey="M"><p>Tì<u>m</u> kiếm</p></Button></td>
        <%else%>
			<%if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),"F27",1)="1" or Session("IsAdmin") then%>
				<td width="17%"><Button language="javascript" name="CmdAdd" onclick="return CmdAdd_onclick()" style=" POSITION: relative; WIDTH:100%" accesskey="T"><u>T</u>hêm</Button></td>
				<td width="17%"><Button disabled language="javascript" name="CmdDelete" onclick="return CmdDelete_onclick()" style=" POSITION: relative; WIDTH:100%" accesskey="X"><u>X</u>óa</Button></td>
				<td width="17%"><Button disabled language="javascript" name="CmdEdit" onclick="return CmdEdit_onclick()" style=" POSITION: relative; WIDTH:100%" accesskey="S"><u>S</u>ửa</Button></td>
				<td width="17%"><Button disabled language="javascript" name="CmdOK" onclick="return CmdOK_onclick()" style="POSITION: relative; WIDTH:100%" accesskey="G"><p><u>G</u>hi nhận</p></Button></td>
				<td width="16%"><Button disabled language="javascript" name="CmdCancel" onclick="return CmdCancel_onclick()" style="POSITION: relative; WIDTH:100%" accesskey="B"><p><u>B</u>ỏ qua</p></Button></td>
			<%else%>
				<td width="17%"><Button disabled language="javascript" name="CmdAdd" onclick="return CmdAdd_onclick()" style=" POSITION: relative; WIDTH:100%" accesskey="T"><u>T</u>hêm</Button></td>
				<td width="17%"><Button disabled language="javascript" name="CmdDelete" onclick="return CmdDelete_onclick()" style=" POSITION: relative; WIDTH:100%" accesskey="X"><u>X</u>óa</Button></td>
				<td width="17%"><Button disabled language="javascript" name="CmdEdit" onclick="return CmdEdit_onclick()" style=" POSITION: relative; WIDTH:100%" accesskey="S"><u>S</u>ửa</Button></td>
				<td width="17%"><Button disabled language="javascript" name="CmdOK" onclick="return CmdOK_onclick()" style="POSITION: relative; WIDTH:100%" accesskey="G"><p><u>G</u>hi nhận</p></Button></td>
				<td width="16%"><Button disabled language="javascript" name="CmdCancel" onclick="return CmdCancel_onclick()" style="POSITION: relative; WIDTH:100%" accesskey="B"><p><u>B</u>ỏ qua</p></Button></td>
			<%end if%>
			<td width="16%"><Button language="javascript" name="CmdSearch" onclick="return CmdSearch_onclick()" style="POSITION: relative; WIDTH:100%" accesskey="M"><p>Tì<u>m</u> kiếm</p></Button></td>
        <%end if%>
    </tr>
  </tbody>
</table>
<!-- Form nhap lieu -->
<table bgColor="#bdd5d0" border="0" cellPadding="0" cellSpacing="0" width="100%" style="BORDER-BOTTOM-STYLE: solid; BORDER-LEFT-STYLE: solid; BORDER-RIGHT-STYLE: solid; BORDER-TOP-STYLE: none;Border-color:#C0C0C0">
  <tbody>
  <%if bDisplay="ok" then%>
    <tr>
      <td width="15%">&nbsp;Họ và tên</td>      
      <td width="35%">
      <input disabled maxlength=30 value="<%=bHoten%>" name=TxtHoten style="width:100%" size="20"></td>
      <td width="15%">&nbsp;E-Mail</td>
      <td width="35%">
      <input disabled maxlength=50 value="<%=bEmail%>" name=TxtEmail style="width:100%" size="20"></td>
    </tr>
    <tr >
      <td width="15%">&nbsp;Phòng ban</td>
      <td width="35%">
		<select size="1" disabled name="Commbonhom" style="font-family: Arial; height: 23; position: relative;width:100%">
		<% 	Set RecT=server.CreateObject("ADODB.Recordset") 
			%><option value=""><%
        	ssql="Select * from Nhom order by STT"
        	RecT.Open ssql,Conn
        	if (not rect.eof )or ( not rect.BOF) then
        		rect.MoveFirst
				Do While Not RecT.eof
				if rect("manhom")<>bIDNhom then	
        	%>
        		<option value="<%=RecT("Manhom")%>"><%=RecT("Tennhom")%>
        		<%else%>
        		<option selected value="<%=RecT("Manhom")%>"><%=RecT("Tennhom")%>
        		<%end if %>
        	<%	RecT.MoveNext
        		Loop
        	END IF
        	RecT.close
        	set RecT=nothing
        	%>                	
        </select>
	  </td>
      <td width="15%">&nbsp;Cơ quan</td>
      <td width="35%">
      <input disabled maxlength=255 value="<%=bCoquan%>" name=TxtCQ style="width:100%" size="20"></td>
    </tr>
    <tr>
      <td width="15%">&nbsp;Tổng đài</td>
      <td width="35%">
      <input disabled maxlength=20 value="<%=bTongdai%>" name=TxtTongdai style="width:100%" size="20"></td>
      <td width="15%">&nbsp;Fax </td>
      <td width="35%">
      <input disabled maxlength=20 value="<%=bFax%>" name=TxtFax style="width:100%" size="20"></td>
    </tr>
    <tr>
      <td width="15%">&nbsp;ÐT Trực tiếp</td>
      <td width="35%">
      <input disabled maxlength=20 value="<%=bPhoneCQ%>" name=TxtPhoneCQ style="width:100%" size="20"></td>
      <td width="15%">&nbsp;ÐT nội bộ </td>
      <td width="35%">
      <input disabled maxlength=20 value="<%=bPhone%>" name=TxtPhone style="width:100%" size="20"></td>
    </tr>
    <tr>
      <td width="15%">&nbsp;ÐT Di động</td>
      <td width="35%">
      <input disabled maxlength=20 value="<%=bPhoneDD%>" name=TxtPhoneDD style="width:100%" size="20"></td>
      <td width="15%">&nbsp;ÐT Nhà riêng</td>
      <td width="35%">
      <input disabled maxlength=20 value="<%=bPhoneNR%>" name=TxtPhoneNR style="width:100%" size="20"></td>
    </tr>
   <%else%>
	<tr >
      <td width="15%">&nbsp;Họ và tên</td>      
      <td width="35%">
      <input disabled maxlength=30 name=TxtHoten style="width:100%" size="20"></td>
      <td width="15%">&nbsp;E-Mail</td>
      <td width="35%">
      <input disabled maxlength=50 name=TxtEmail style="width:100%" size="20"></td>
    </tr>
    <tr >
      <td width="15%">&nbsp;Phòng ban</td>
      <td width="35%">
		<select size="1" disabled name="Commbonhom" style="font-family: Arial; height: 23; position: relative; width:100%">
			<option value="">
        <% 	Set RecT=server.CreateObject("ADODB.Recordset") 
        	ssql="Select * from Nhom order by tennhom"
        	RecT.Open ssql,Conn
        	if (not rect.eof )or ( not rect.BOF) then
        		rect.MoveFirst
				Do While Not RecT.eof     
				if rect("manhom")<>bIDNhom then	
        	%>
        		<option value="<%=RecT("Manhom")%>"><%=RecT("Tennhom")%>
        		<%else%>
        		<option selected value="<%=RecT("Manhom")%>"><%=RecT("Tennhom")%>
        		<%end if %>
        	<%	RecT.MoveNext
        		Loop
        	END IF
        	RecT.close
        	set RecT=nothing
        	%>                	
        </select>
	  </td>
      <td width="15%">&nbsp;Cơ quan</td>
      <td width="35%">
      <input disabled maxlength=255 name=TxtCQ style="width:100%" size="20"></td>
    </tr>
    <tr>
      <td width="15%">&nbsp;Tổng đài</td>
      <td width="35%">
      <input disabled maxlength=20 name=TxtTongdai value="<%=bTD%>" style="width:100%" size="20"></td>
      <td width="15%">&nbsp;Fax</td>
      <td width="35%">
      <input disabled maxlength=20 name=TxtFax style="width:100%" size="20"></td>
    </tr>
    <tr>
      <td width="15%">&nbsp;ÐT Trực tiếp</td>
      <td width="35%">
      <input disabled maxlength=20 name=TxtPhoneCQ style="width:100%" size="20"></td>
      <td width="15%">&nbsp;ÐT nội bộ</td>
      <td width="35%">
      <input disabled maxlength=20 name=TxtPhone style="width:100%" size="20"></td>
    </tr>
    <tr>
      <td width="15%">&nbsp;ÐT Di động</td>
      <td width="35%">
      <input disabled maxlength=20 name=TxtPhoneDD style="width:100%" size="20"></td>
      <td width="15%">&nbsp;ÐT Nhà riêng</td>
      <td width="35%">
      <input disabled maxlength=20 name=TxtPhoneNR style="width:100%" size="20"></td>
    </tr>
   <%end if%>
  </tbody>
</table>

<table  border="0" width="100%" style="Border-color:#C0C0C0;BORDER-BOTTOM-STYLE: solid; BORDER-LEFT-STYLE: solid; BORDER-RIGHT-STYLE: solid; BORDER-TOP-STYLE: none;">
  <tr>
    <td width="100%" colspan="5" bgcolor="#173584" ALIGN="CENTER"><FONT COLOR=WHITE FACE=arial  SIZE=2><B>(Số tổng đài: <%=bTD%>)</B></font></td>
  </tr>
  <tr bgcolor="#bdd5d0">
    <td width="40%" align="center">Họ và tên</td>
    <td width="15%" align="center">Trực tiếp</td>
    <td width="15%" align="center">Nội bộ </td>
    <td width="15%" align="center">Di động</td>
    <td width="15%" align="center">Nhà riêng</td>
  </tr>
  <%	
	If Not Rec.Eof Then
		nRecCount = Rec.RecordCount
		Rec.PageSize = 20
		nPageCount = Rec.PageCount
		If nPage < 1 then
			nPage = 1
		End If
		if nPage > nPageCount Then
			nPage=nPageCount
		end if
		cnt=(pg-1)*pgsize + 1		    
		STT=1
		rec.AbsolutePage=nPage
		howmanyrecs=0
		do while not Rec.EOF and howmanyrecs<rec.PageSize
%>
			<%if Rec("IDNhom")<>bIDTruoc then%>
			<tr bgcolor=#eeeecc>
				<TD colspan="5" align=left><font color=brown><b><%=Rec("Tennhom")%></b></font></TD>
			</tr>			
			<%End if%>
			<%bIDTruoc=Rec("IDNhom")%>			
			<tr bgcolor=#F8F9D9>
				<td width="40%"><a style='text-decoration: none;color=blue' href=Phone.asp?bdisplay=ok&bIDPhone=<%=Rec("IDPhone")%> target=right><%=Rec("Hoten")%></a></td>
				<td width="15%"><a style='text-decoration: none;color=blue' href=Phone.asp?bdisplay=ok&bIDPhone=<%=Rec("IDPhone")%> target=right><%=Rec("PhoneCQ")%></a></td>
				<td width="15%"><a style='text-decoration: none;color=blue' href=Phone.asp?bdisplay=ok&bIDPhone=<%=Rec("IDPhone")%> target=right><%=Rec("Phone")%></a></td>
				<td width="15%"><a style='text-decoration: none;color=blue' href=Phone.asp?bdisplay=ok&bIDPhone=<%=Rec("IDPhone")%> target=right><%=Rec("PhoneDD")%></a></td>
				<td width="15%"><a style='text-decoration: none;color=blue' href=Phone.asp?bdisplay=ok&bIDPhone=<%=Rec("IDPhone")%> target=right><%=Rec("PhoneNR")%></a></td>
			</tr>
<%			STT=STT+1
			Rec.MoveNext
			cnt=cnt+1
			howmanyrecs=howmanyrecs+1
		loop
	end if
	rec.Close
	set rec=nothing
	
%>  
</Table>
<input type=hidden name=TxtMa value="<%=bIDPhone%>">
<input type=hidden name=sua>
<input type=hidden name=TxtHotenS value="<%=bHoten%>">
<input type=hidden name=TxtCQS value="<%=bCoQquan%>">
<input type=hidden name=TxtPhoneS value="<%=bPhone%>">
<input type=hidden name=TxtPhoneCQS value="<%=bPhoneCQ%>">
<input type=hidden name=TxtPhoneNRS value="<%=bPhoneNR%>">
<input type=hidden name=TxtPhoneDDS value="<%=bPhoneDD%>">

 <!-- Phan trang -->
<br>
<table width="98%" cellspacing=0 cellpadding=0>
<tr>
<% if nPage > 0 and nPageCount >0  then %>  
	<td width="20%"><b>Trang&nbsp; <%=nPage%>/<%=nPageCount%></b></td>
<!-- 	<td width= "80%" align="right">
	<% if nPageCount > 1 then %>    
		Chuyển nhanh tới trang:&nbsp;
		<select name="page" style="width:45;height:23;font-size:8pt" size=1 onchange="javaScript:ChangePage()">
			<% for i = 1 to nPageCount%>	
				<% if bComm<>"search"  then
					strURL="phone.asp?bsearch="& bsearch &"&Loaitim="& loaitim &"&page="+ cstr(i) + "&bComm="
				else
					strURL="phone.asp?bsearch="& bsearch &"&Loaitim="& loaitim &"&page="+ cstr(i) + "&bComm=search"
				end if %>
				<option value="<%=strURL%>" <%=chkSelected(i, nPage)%>><%=i%></option>
			<% next %>    
		</select>
		</td>                                  
	<% end if %> -->             
<% 'else %>
<% end if %>
<td width= "80%" align="center"><%=Paging(nPage, nPageCount, nRecCount)%></td>
</tr>
</table>
</body>
</form>
<SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
<!--
function SetFocus(){
	if (!frm.CmdSearch.disabled){
		window.frm.CmdSearch.focus();
	}
}

function ChangePage(){
	strURL=frm.page.value;
	window.frm.action=strURL;
	window.frm.submit();
}

function KTnhap(){
	if (frm.TxtHoten.value==""){
		alert("Bạn cần phải nhập tên");
		frm.TxtHoten.focus();
		return false;
	}
	if (frm.Commbonhom.value==""){
		alert("Cho biết phòng ban");
		frm.Commbonhom.focus();
		return false;
	}
	if (frm.TxtCQ.value==""){
		alert("Bạn phải nhập cơ quan");
		frm.TxtCQ.focus();
		return false;
	}
	return true;
}
function CmdAdd_onclick() {
	Unlockdata();
	frm.TxtMa.value="";
	frm.TxtHoten.value="";
	frm.TxtEmail.value="";
	frm.TxtCQ.value="";
	frm.TxtTongdai.value="<%=bTD%>";
	frm.TxtFax.value="";
	frm.TxtPhone.value="";
	frm.TxtPhoneCQ.value="";
	frm.TxtPhoneDD.value="";
	frm.TxtPhoneNR.value="";
	frm.Commbonhom.disabled=false;
	cmdenable(false);	
	frm.TxtHoten.focus();
	frm.sua.value="2";
}
function cmdenable(bvalue){
	if (bvalue){
		frm.CmdAdd.disabled= false;
		frm.CmdDelete.disabled= false;
		frm.CmdEdit.disabled= false;
		frm.CmdCancel.disabled= true;
		frm.CmdOK.disabled= true;	
		frm.CmdSearch.disabled=false;
	}
	else {
		frm.CmdAdd.disabled= true;
		frm.CmdDelete.disabled= true;
		frm.CmdEdit.disabled= true;
		frm.CmdCancel.disabled= false;
		frm.CmdOK.disabled= false;
		frm.CmdSearch.disabled=true;
	}	
	frm.CmdSearch.value="Tì<u>m</u> kiếm";
}

function CmdCancel_onclick() {
	cmdenable(true);
	frm.CmdDelete.disabled= true;
	frm.CmdEdit.disabled= true;
	Lockdata();	
	frm.TxtMa.value="";
	frm.TxtHoten.value="";
	frm.TxtEmail.value="";
	frm.TxtCQ.value="";
	frm.TxtTongdai.value="";
	frm.TxtFax.value="";
	frm.TxtPhoneDD.value="";
	frm.TxtPhoneNR.value="";
	frm.TxtPhone.value="";
	frm.TxtPhoneCQ.value="";
}

function Lockdata(){
	frm.TxtMa.disabled=true;
	frm.TxtHoten.disabled=true;
	frm.TxtEmail.disabled=true;	
	frm.TxtCQ.disabled=true;
	frm.TxtTongdai.disabled=true;
	frm.TxtFax.disabled=true;
	frm.TxtPhone.disabled=true;
	frm.TxtPhoneCQ.disabled=true;
	frm.TxtPhoneDD.disabled=true;
	frm.TxtPhoneNR.disabled=true;
	frm.Commbonhom.disabled=true;
}
function Unlockdata(){
	frm.TxtMa.disabled=false;
	frm.TxtEmail.disabled=false;
	frm.TxtCQ.disabled=false;
	frm.TxtHoten.disabled=false;
	frm.TxtTongdai.disabled=false;
	frm.TxtFax.disabled=false;
	frm.TxtPhone.disabled=false;
	frm.TxtPhoneCQ.disabled=false;
	frm.TxtPhoneDD.disabled=false;
	frm.TxtPhoneNR.disabled=false;
	frm.Commbonhom.disabled=false;
	
}
function CmdDelete_onclick() {
	if (frm.TxtMa.value==""){
		alert("Bạn hãy  chọn thông tin cần xóa");
		return ;
	}
	if(!confirm("Bạn có muốn xóa không ?")){
		return false;	
	}
	window.frm.target="right";
	window.frm.action="phone.asp?bComm=delete";
	window.frm.submit();
}
function CmdEdit_onclick() {
	if (frm.TxtMa.value==""){
		alert("Bạn hãy chọn thông tin cần sửa");
		return ;
	}
	cmdenable(false);
	Unlockdata();
	frm.TxtHoten.focus();
	frm.sua.value="1";
}
function CmdOK_onclick() {
	if (KTnhap()){
		if(frm.sua.value=="2"){
			frm.action="phone.asp?bComm=add";
		}
		if(frm.sua.value=="1"){
			frm.action="phone.asp?bComm=edit";
		}
		frm.Commbonhom.disabled=false;		
		frm.target="right";
		frm.submit();
	}
}
function CmdLoc_onclick() {
	Unlockdata();
	frm.TxtMa.focus();
}
function CmdSearch_onclick() {
	<%if Session("ClsFun").LayGiaTriQuyen(Session("Permision"),"F27",1)="1"  or Session("IsAdmin") then%>
		frm.CmdAdd.disabled=true;
		frm.CmdCancel.disabled=false;
		frm.CmdEdit.disabled=true;
		frm.CmdDelete.disabled=true;
	<%end if%>
	if (frm.TxtHoten.disabled){
		frm.CmdSearch.value="Tì<u>m</u>";
		Unlockdata()
		frm.TxtCQ.value="";		
		frm.TxtMa.value="";
		frm.TxtHoten.value="";
		frm.TxtEmail.value="";
		frm.TxtTongdai.value="";
		frm.TxtFax.value="";
		frm.TxtPhone.value="";
		frm.TxtPhoneCQ.value="";
		frm.TxtPhoneDD.value="";
		frm.TxtPhoneNR.value="";
		frm.TxtHoten.value="";
		frm.TxtHoten.focus();
		frm.Commbonhom.disabled=false;
		return false;
	}
	blink="phone.asp?bComm=search";
	window.frm.action=blink;
	window.frm.target="right"
	window.frm.submit();	
}
//-->
</script>
</font>
</HTML>